import base64

from django.db import models

# Create your models here.

from django.db import models


# Create your models here.
class Award(models.Model):  # 荣誉模型
    description = models.TextField(max_length=500, blank=True, null=True, verbose_name='荣誉描述')
    photo = models.ImageField(upload_to='Award/', blank=True, verbose_name='荣誉照片')

    def get_file_base64(self):
        with open(self.photo.path, "rb") as image_file:
            encoded_string = base64.b64encode(image_file.read()).decode("utf-8")
        return encoded_string

    class Meta:
        verbose_name = '获奖和荣誉'
        verbose_name_plural = '获奖和荣誉'
